Hi,
I want to replace a particular word by one object text. I want to perform following steps: 1. Copy one object text & store it to program memory 2. Loop through the all object text and find the particular word say 'test' 3. Now replace all the 'test' words found by a object text copied to program memory in step 1. I couldn't find the function to copy the object text. Please help me with this.
Thanks -Amol Amol_S - Thu Jul 06 22:20:11 EDT 2017 |
Re: Replace text by Object Object o=current string oTxt=o."Object Text" Of course the work is easy if it is just plain text. But you may need to worry about rich text markup, and also embedded OLE content, which will complicate matters. |
Re: Replace text by Object strathglass - Fri Jul 07 09:23:00 EDT 2017 Object o=current string oTxt=o."Object Text" Of course the work is easy if it is just plain text. But you may need to worry about rich text markup, and also embedded OLE content, which will complicate matters. I want that complicated matter, replace text by embedded ole. Yet struggling with it. |
Re: Replace text by Object Hello!
This might be a bit brute force, I haven't tested it yet, but it might help. I haven't finished it yet, on Monday I'll continue
Object o = current
Module m = current
string strText = ""
string strReplacer = ""
strReplacer = o."Object Text" ""
int iContains = 0
Buffer buf = create()
for o in m do{
strText = o."Object Text"
buf = strText
iContains = 0
while (iContains != -1){
strText = o."Object Text"
buf = strText
iContains = contains (buf, '\n' , offset)
}
}
|
Re: Replace text by Object Hello!
Here's the final code, I'd suggest playing with it a bit in a sandbox, or something like that. I haven't tested is yet, might contain some errors.
Object o = current
Module m = current
string strText = ""
string strReplacer = ""
strReplacer = o."Object Text" ""
int iContains = 0
Buffer buf = create()
for o in m do{
strText = o."Object Text"
buf = strText
iContains = 0
while (iContains != -1){
strText = o."Object Text"
buf = strText
iContains = contains (buf, "test" , 0)
if (iContains != -1){
strText = strText[0:iContains-1] "" strReplacer "" strText[iContains+4:] ""
o."Object Text" = strText ""
}
}
}
ack "all done"
|